﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DLL;
using Module;

namespace BLL
{
    public class BUserProfile
    {

        #region 字段

        private DUserProfile APP = new DUserProfile();//数据操作对象
        private static BUserProfile instance;

        #endregion

        #region 公共接口

        /// <summary>
        /// 取得
        /// </summary>
        /// <returns>BBlog对象</returns>
        public static BUserProfile getInstance()
        {
            if (instance == null)
            {
                instance = new BUserProfile();
            }
            return instance;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="userProfileInfo"></param>
        /// <returns></returns>
        public bool Insert(UserProfileInfo userProfileInfo)
        {
            if (userProfileInfo == null || userProfileInfo.UserPassportId.ToString().Length != 18)
            {
                return false;
            }
            return APP.Insert(userProfileInfo);
        }

        /// <summary>
        /// 更新用户属性
        /// </summary>
        /// <param name="userProfileInfo"></param>
        /// <returns></returns>
        public bool Update(UserProfileInfo userProfileInfo)
        {
            if (userProfileInfo == null || userProfileInfo.UserPassportId.ToString().Length != 18)
            {
                return false;
            }
            return APP.Update(userProfileInfo);
        }
         /// <summary>
        /// 获取用户属性
        /// </summary>
        /// <param name="userPassportId"></param>
        /// <returns></returns>
        public UserProfileInfo GetUserProfileInfo(long userPassportId)
        {
            if (userPassportId == 0 || userPassportId.ToString().Length != 18)
                return null;
            return APP.GetUserProfileInfo(userPassportId);
        }

        /// <summary>
        /// 获取用户属性
        /// </summary>
        /// <param name="userPassportId"></param>
        /// <returns></returns>
        public UserProfileInfo GetUserProfileInfoByPhone(string phonde)
        {
            if (string.IsNullOrWhiteSpace(phonde))
                return null;
            return APP.GetUserProfileInfoByPhone(phonde);
        }
        
        /// <summary>
        /// 获取所有有效用户的属性
        /// </summary>
        /// <returns></returns>
        public List<UserProfileInfo> GetALLUserProfile()
        {
            return APP.GetALLUserProfile();
        }
        /// <summary>
        /// 根据用户类型获取有效用户属性
        /// </summary>
        /// <param name="userType"></param>
        /// <returns></returns>
        public List<UserProfileInfo> GetALLUserProfileByUserType(int userType)
        {
            if (userType == 0)
                return null;
            return APP.GetALLUserProfileByUserType(userType);
        }
        /// <summary>
        /// 根据Email查找用户
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        public UserProfileInfo GetUserProfileInfo(string email)
        {
            if (string.IsNullOrEmpty(email))
                return null;
            return APP.GetUserProfileInfo(email);
        }
        #endregion
    }
}
